<template>
  <div class="dashboard-container">
    	<el-row class="panel-group" :gutter="40">

    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-money">
          <svg-icon icon-class="indicator" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">指标数：</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="indicationTotal" :duration="3200"></count-to>
        </div>
      </div>
    </el-col>
    
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class='card-panel'>
        <div class="card-panel-icon-wrapper icon-people">
          <svg-icon icon-class="eye" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">观测点数:</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="visitPointTotal" :duration="2600"></count-to>
        </div>
      </div>
    </el-col>
    
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" >
        <div class="card-panel-icon-wrapper icon-message">
          <svg-icon icon-class="peoples" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">专业数：</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="professionTotal" :duration="3000"></count-to>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel">
        <div class="card-panel-icon-wrapper icon-shoppingCard">
          <svg-icon icon-class="form" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">专业分数:</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="professionGradeTotal" :duration="3600"></count-to>
        </div>
      </div>
    </el-col>
 </el-row>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import CountTo from "vue-count-to";
import {getIndicatorCount} from "@/api/indicator";
import {getProfessionCount} from "@/api/profession";
import {getProfessionGradeCount} from "@/api/professionGrade";

export default {  
  name: "dashboard",
  computed: {
    ...mapGetters(["name", "roles"])
  },
  components: {
    CountTo
  },
  data() {
    return {
      indicationTotal: 0,
      visitPointTotal: 0,
      professionTotal: 0,
      professionGradeTotal: 0,      
    }
  },
  created() {
    var params = new URLSearchParams();
    params.append("typeStatus", "0");
    getIndicatorCount(params).then(response => {
      if(response.code == "success") {
        this.indicationTotal = response.data;
      }
    })

    var params2 = new URLSearchParams();
    params2.append("typeStatus", "1");
    getIndicatorCount(params2).then(response => {
      if(response.code == "success") {
        this.visitPointTotal = response.data;
      }
    })

    getProfessionCount().then(response => {
      if(response.code == "success") {
        this.professionTotal = response.data;
      }
    })

    getProfessionGradeCount().then(response => {
      if(response.code == "success") {
        this.professionGradeTotal = response.data;
      }
    })
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.btn {
  width: 80px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 14px;
  display: inline-block;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
}

.btnClick {
  color: #409eff;
  border-color: #c6e2ff;
  background-color: #ecf5ff;
}

.btn:hover {
  color: #409eff;
  border-color: #c6e2ff;
  background-color: #ecf5ff;
}

.statistics-item {
  width: 600px;
  height: 400px;
  float: left;
  margin: 20px auto;
}

.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }
      .icon-people {
        background: #40c9c6;
      }
      .icon-message {
        background: #36a3f7;
      }
      .icon-money {
        background: #f4516c;
      }
      .icon-shoppingCard {
        background: #34bfa3;
      }
    }
    .icon-people {
      color: #40c9c6;
    }
    .icon-message {
      color: #36a3f7;
    }
    .icon-money {
      color: #f4516c;
    }
    .icon-shoppingCard {
      color: #34bfa3;
    }
    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }
    .card-panel-icon {
      float: left;
      font-size: 48px;
    }
    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px 70px 0 0;
      .card-panel-text {
        line-height: 18px;;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }
      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}
</style>
